len-caching-lock 0.1.1

Atomically cached len(), for use with collections contained in parking_lot Mutex and RwLock
Documentation

This crate allows automatic caching of T.len() with an api that allows drop in replacement for parking_lot Mutex and RwLock for most common use-cases.

This crate implements Len for the following types: std::collections::{VecDeque, LinkedList, HashMap, BTreeMap, HashSet, BTreeSet, BinaryHeap}

Example

extern crate len_caching_lock;
use len_caching_lock::LenCachingMutex;

fn main() {
let vec: Vec<i32> = Vec::new();
let len_caching_mutex = LenCachingMutex::new(vec);
assert_eq!(len_caching_mutex.lock().len(), len_caching_mutex.load_len());
len_caching_mutex.lock().push(0);
assert_eq!(1, len_caching_mutex.load_len());
}